package common

import (
	"io"

	"spider/thirdparty/xpath.v1"
)

type Selecter struct {
	content io.Reader
}

func (self *Selecter) XmlPath(path string) (item []string, err error) {
	xp, err := xpath.MustCompile(path)
	if err != nil {
		return nil, err
	}
	root, err := xpath.ParseHTML(self.content)
	if err != nil {
		return nil, err
	}
	iter := xp.Iter(root)
	for iter.Next() {
		item = append(item, iter.Node().String())
	}
	return
}
